package common

import (
	"encoding/json"
	"fmt"
)

type RespApiBase struct {
	Code int             `json:"code"`
	Msg  string          `json:"msg"`
	Data json.RawMessage `json:"data"`
}

func (r *RespApiBase) UnmarshalData(v any) error {
	return json.Unmarshal(r.Data, v)
}

func (r *RespApiBase) Error() string {
	return fmt.Sprintf("code: %d, msg: %s", r.Code, r.Msg)
}
